{% extends 'admin/base.html' %}
{% block mainbody %}
    <h3>
        会员信息管理
    </h3>
    <form id="edit-profile" onsubmit="return checkinput();" action="{% url 'myadmin_users_insert' %}" class="form-horizontal" method="post">
        {% csrf_token %}
        <fieldset>
            <legend>添加会员信息</legend>
            <div class="control-group">
                <label class="control-label" for="account">账号：</label>
                <div class="controls">
                    <input type="text" name="username" class="input-xlarge" id="account" value="" />
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="pwd1">密码：</label>
                <div class="controls">
                    <input type="password" name="password" class="input-xlarge" id="pwd1"/>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="pwd2">重复密码：</label>
                <div class="controls">
                    <input type="password" name="repassword" class="input-xlarge" id="pwd2"/>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="realname">真实姓名：</label>
                <div class="controls">
                    <input type="text" name="name" class="input-xlarge" id="realname"/>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="input05">性别：</label>
                <div class="controls">
                    <input type="radio" name="sex" class="input-xlarge" id="input05" value="1" /> 男
                    <input type="radio" name="sex" class="input-xlarge" id="input051" value="0" /> 女
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="input06">地址：</label>
                <div class="controls">
                    <input type="text" name="address" class="input-xlarge" id="input06"/>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="input07">邮编：</label>
                <div class="controls">
                    <input type="text" name="code" class="input-xlarge" id="input07"/>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="input08">电话：</label>
                <div class="controls">
                    <input type="text" name="phone" class="input-xlarge" id="input08"/>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="input09">email邮箱：</label>
                <div class="controls">
                    <input type="text" name="email" class="input-xlarge" id="input09"/>
                </div>
            </div>
            <div class="form-actions">
                <button type="submit" class="btn btn-primary">添加</button> <button type="reset" class="btn">重置</button>
            </div>
        </fieldset>
    </form>
    <script type="text/javascript">
        function checkinput () {
            var errmsg="";
            // 账户、真实姓名不能为空
            var account=$("#account").val();
            var realname=$("#realname").val();
            if(account==""){
                errmsg="请输入账户!";
            }else if(realname==""){
                errmsg="请输入真实姓名!";
            }else{
                //密码是否一致
                var pwd1=$("#pwd1").val();
                var pwd2=$("#pwd2").val();
                if(pwd1==""){
                    errmsg="请输入密码!";
                }else if(pwd1!=pwd2){
                    errmsg="两次输入密码不一致！";
                }
            }
            if(errmsg!=""){
                alert(errmsg)
                return false;
            }
        }
    </script>
{% endblock %}